//
//  KDSignChildController.m
//  WangJingApp
//
//  Created by 魏强 on 17/1/24.
//  Copyright © 2017年 KDTech. All rights reserved.
//  未签收列表

#import "KDSignChildController.h"
#import "KDUnsignedCell.h"
#import "IQTextView.h"
@interface KDSignChildController ()<UITableViewDelegate, UITableViewDataSource, KDUnsignedCellDelegate>
/**  底部scroll */
@property (nonatomic, weak) UIScrollView *underScroll;

/**  <#Description#> */
@property (nonatomic, weak) UITableView *tableView;
/**  所有已签收数据 */
@property (nonatomic, strong) NSArray *infoArr;

@property (nonatomic, copy) NSString * cellId;
/**  <#Description#> */
@property (nonatomic, weak) UIView *commentView;
/**  发送按钮 */
@property (nonatomic, weak) UIButton *postBtn;

@end

@implementation KDSignChildController
#pragma mark - 懒加载区
- (NSArray *)infoArr
{
    if (!_infoArr) {
        _infoArr = [[NSArray alloc]init] ;
    }
    return _infoArr;
}
#pragma mark - 生命周期区
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BackGroundColor;
    // Do any additional setup after loading the view from its nib.
    [self setupScroll];
    [self setupTableView];
    [self setupCommentView];
    [self setpuPostBtn];
    
}
#pragma mark - 板块布置区
- (void)setupTableView{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0  , 0, screenW,  self.view.height *0.6) style:UITableViewStylePlain];
    self.tableView = tableView;
    tableView.delegate = self;
    tableView.dataSource = self;
//    tableView.scrollEnabled = NO;
    tableView.tableFooterView = [UIView new];
    tableView.separatorColor = BackGroundColor;
    tableView.backgroundColor = BackGroundColor;
    [self.underScroll addSubview:tableView];
    //    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
    self.cellId = @"KDUnsignedCell";
    UINib *xib = [UINib nibWithNibName:self.cellId bundle:nil];
    
    [self.tableView registerNib:xib forCellReuseIdentifier:self.cellId];
    //    self.tableView.separatorColor = WQColor(245, 245, 245);
    
    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadData)];
    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    [footer setTitle:@"" forState:MJRefreshStateIdle];
    // 设置footer
    self.tableView.footer = footer;
    [self.tableView.header beginRefreshing];
}

- (void)setupCommentView{
    UIView *commentView = [[UIView alloc]init];
    self.commentView = commentView;
    commentView.frame = CGRectMake(0, CGRectGetMaxY(self.tableView.frame), screenW , 120);
    [self.underScroll addSubview:commentView];
    IQTextView *textView = [[IQTextView alloc]initWithFrame:CGRectMake(10, 10, screenW - 20, 100)];
    [commentView addSubview:textView];
    textView.placeholder = @"请输入督办内容";
    textView.layer.cornerRadius = 10;
    textView.layer.borderWidth = 1;
    textView.layer.borderColor = WQColor(234, 234, 234).CGColor;
    
}
- (void)setpuPostBtn{
    UIButton *postBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    postBtn.frame = CGRectMake(20, CGRectGetMaxY(self.commentView.frame) + 10 , screenW - 40, 44);
    [postBtn setTitle:@"发送" forState:UIControlStateNormal];
    [postBtn addTarget:self action:@selector(postBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    postBtn.backgroundColor = KDColor;
    [postBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    postBtn.layer.cornerRadius = 5;
    postBtn.clipsToBounds = YES;
    self.postBtn = postBtn;
    [self.underScroll addSubview:postBtn];
    self.underScroll.contentSize = CGSizeMake(0, CGRectGetMaxY(self.postBtn.frame) + 144);
}
- (void)setupScroll{
//    //加一个挡板
//    UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
//    view.backgroundColor = [UIColor clearColor];
//    [self.view addSubview:view];
    //初始化underScrollView
    UIScrollView *underScroll = [[UIScrollView alloc]init];
    self.underScroll = underScroll;
    underScroll.frame = CGRectMake(0, 0, screenW, self.view.height);
    
    underScroll.backgroundColor = BackGroundColor;
    underScroll.showsHorizontalScrollIndicator = NO;
    underScroll.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.underScroll];

}
#pragma mark - 事件点击区
/**  发送按钮被点击了 */
- (void)postBtnClick:(UIButton *)postBtn{
    
}
#pragma mark - 网络请求区
- (void)loadData{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.tableView.header endRefreshing];
    });
}
- (void)loadMoreData{
    
}
#pragma mark - 通知接收区

#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    KDUnsignedCell *cell = [KDUnsignedCell cellWithTableView:tableView];
    //    cell.delegate = self;
    //    if (self.infoArr.count != 0) {
    //        cell.model = self.infoArr[indexPath.row];
    //    }
    return cell;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - KDUnsignedCellDelegate
/**  选中按钮被点击了 */
- (void)unsignedCell:(KDUnsignedCell *)cell selectBtnClick:(UIButton *)selectBtn{
    
}
@end
